package main

import (
	"context"
	"fmt"
	"go.etcd.io/etcd/client/v3"
	"time"
)

func main() {
	var (
		config clientv3.Config
		client *clientv3.Client
		kv clientv3.KV
		err error
		getResp *clientv3.GetResponse
	)
	config = clientv3.Config{
		Endpoints: []string{"47.106.109.134:2379"},
		DialTimeout: 5 * time.Second,
	}
	if client, err = clientv3.New(config); err != nil {
		fmt.Println(err)
		return
	}
	// get目录下所有值
	kv = clientv3.NewKV(client)
	if getResp, err = kv.Get(context.TODO(), "foo", clientv3.WithPrefix()); err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(getResp.Kvs)
}